package com.sundae.service.impl;

import com.sundae.beans.User;
import com.sundae.mapper.UserMapper;
import com.sundae.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by superace on 2017/8/7.
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String userName) {
        return userMapper.getUserByUserName(userName);
    }

    @Override
    public boolean register(User user) {
        if(userMapper.getUserByUserName(user.getUsername()) == null) {
            userMapper.addUser(user);
            return true;
        }
        return false;
    }
}
